Skip to content

feat(tasks): Sprint 1 M9 — x402 payment flow, EIP-2612 permit, receipt display#279

Closed
fanhousanbu wants to merge 2 commits intofeat/m7-guardian-tier-recoveryfrom
feat/mytask-sprint1-m9
Closed

feat(tasks): Sprint 1 M9 — x402 payment flow, EIP-2612 permit, receipt display#279
fanhousanbu wants to merge 2 commits intofeat/m7-guardian-tier-recoveryfrom
feat/mytask-sprint1-m9

Conversation

@fanhousanbu
Copy link
Copy Markdown
Collaborator

@fanhousanbu fanhousanbu commented Apr 2, 2026

Summary

Sprint 1 MyTask M9 完整实现,含三个任务:

  • T02 createTaskWithPermit — EIP-2612 单 tx 创建任务(无需单独 approve),不支持时自动降级
  • T05 lib/x402-client.ts — x402 EIP-3009 支付客户端:POST → 402 → sign → retry → receiptId;NEXT_PUBLIC_X402_API_URL 未配置时优雅跳过
  • T06 任务详情页自动 linkReceipt(创建后立即链上绑定),收据卡片显示 payer + 时间戳

Create task flow

[x402]     POST /tasks → 402 → sign EIP-3009 → retry → receiptId
[on-chain] createTaskWithPermit  (fallback: approve + createTask)
[link]     linkReceipt(taskId, receiptId, receiptUri)

New / changed files

File Change
lib/x402-client.ts NEW — x402 client (postTaskWithX402, fetchReceiptDetails)
lib/contracts/task-config.ts add X402_API_URL, REWARD_TOKEN_NAME/VERSION, isX402Configured()
app/tasks/create/page.tsx 3-step flow: x402 → permit → linkReceipt
app/tasks/[taskId]/page.tsx receipt cards with payer + timestamp from API

Test plan

  • Set NEXT_PUBLIC_X402_API_URL=http://localhost:3401 in .env.local
  • Start anvil + deploy: forge script script/DeployLocal.s.sol --broadcast
  • Start API server: cd MyTask/packages/api-server && pnpm start
  • npm run dev → create a task
  • MetaMask 依次弹出:x402 sign → permit sign → tx → receipt linked
  • Task detail 显示 receipt ID、payer、时间戳
  • 移除 NEXT_PUBLIC_X402_API_URL → 任务仍可创建(无收据,降级模式)

…ipts

T01: 积分余额展示
- TaskContext 新增 taskTokenBalance / loadTaskTokenBalance
- Dashboard 新增 Task Reward Balance 卡片,实时读取 ERC-20 余额

T02: createTaskWithPermit
- TASK_ESCROW_ABI 补充 createTaskWithPermit / ERC20 nonces / name / permit
- 创建任务时优先走 EIP-2612 permit(单 tx 无需 approve)
- permit 失败自动降级为 approve + createTask

T06: linkReceipt 前端
- ABI 补充 linkReceipt / getTaskReceipts
- TaskContext 新增 getTaskReceipts / linkReceipt
- 任务详情页新增 x402 Receipts 区域:显示已绑定收据,参与方可手动 link
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

T05 — X402Client integration (lib/x402-client.ts):
- postTaskWithX402: POST /tasks → 402 → sign EIP-3009 → retry → receiptId
- fetchReceiptDetails: GET /receipts/:id for richer display
- Graceful degradation when NEXT_PUBLIC_X402_API_URL not set

T06 — Receipt display & auto-link:
- create/page.tsx: x402 sign → createTaskWithPermit → auto linkReceipt (3-step)
- [taskId]/page.tsx: show payer + timestamp per receipt, fetched from API
- task-config.ts: add X402_API_URL, REWARD_TOKEN_NAME/VERSION, isX402Configured()
@fanhousanbu fanhousanbu changed the title feat(tasks): Sprint 1 M9 — ERC-20余额、EIP-2612 permit、x402收据 feat(tasks): Sprint 1 M9 — x402 payment flow, EIP-2612 permit, receipt display Apr 7, 2026
@fanhousanbu fanhousanbu closed this Apr 7, 2026
@fanhousanbu fanhousanbu deleted the feat/mytask-sprint1-m9 branch April 7, 2026 07:30
@fanhousanbu fanhousanbu mentioned this pull request Apr 7, 2026
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant